<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('文章列表')"/>
    <th:block th:include="include :: bootstrap-select-css"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul id="element">
                        <li>
                            <label>标题：</label>
                            <input type="text" name="title"/>
                        </li>
                        <li>
                            <label>内容：</label>
                            <input type="text" name="content"/>
                        </li>
                        <li>
                            类型：<select class="type" name="type_1"></select>
                        </li>
                        <li>
                            子类型：<select class="router" name="tMenuId"></select>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="fireman:article:add">
                <i class="fa fa-plus"></i> 添加
            </a>
            <a class="btn btn-primary single disabled" onclick="$.operate.edit()"
               shiro:hasPermission="fireman:article:edit">
                <i class="fa fa-edit"></i> 修改
            </a>
            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()"
               shiro:hasPermission="fireman:article:remove">
                <i class="fa fa-remove"></i> 删除
            </a>
            <!--            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="fireman:article:export">-->
            <!--                <i class="fa fa-download"></i> 导出-->
            <!--            </a>-->
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<div class="modal inmodal fade" id="myModal5" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span
                        class="sr-only">Close</span>
                </button>
                <h4 class="modal-title">窗口标题</h4>
                <!--                <small class="font-bold">这里可以显示副标题。</small>-->
            </div>
            <div class="modal-body">
                <!--                <p><strong>RuoYi</strong>是一个完全响应式，基于Bootstrap3.3.7最新版本开发的扁平化主题，她采用了主流的左右两栏式布局，使用了Html5+CSS3等现代技术，她提供了诸多的强大的可以重新组合的UI组件，并集成了最新的jQuery版本(v2.1.1)，当然，也集成了很多功能强大，用途广泛的jQuery插件，她可以用于所有的Web应用程序，如网站管理后台，网站会员中心，CMS，CRM，OA等等，当然，您也可以对她进行深度定制，以做出更强系统。-->
                <!--                </p>-->
            </div>

            <div class="modal-footer">
                <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary">保存</button>
            </div>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: bootstrap-select-js"/>
<th:block th:include="include :: jquery-cxselect-js"/>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('fireman:article:edit')}]];
    var removeFlag = [[${@permission.hasPermi('fireman:article:remove')}]];
    var prefix = ctx + "fireman/article";
    var myData = [];

    $('#element').cxSelect({
        selects: ['type', 'router'],
        jsonValue: 'id',
        jsonName: 'name',
        jsonSub: 'sonMenuList',
        url: prefix + "/menus"
    });

    function showArticle(index) {
        $("#myModal5 h4.modal-title").text(myData[index].title);
        $("#myModal5 div.modal-body").html(myData[index].content);
        return false;
    }

    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "文章",
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: '主键',
                    visible: false
                },
                {
                    field: 'title',
                    title: '文章标题'
                },
                {
                    field: 'readNumber',
                    title: '阅读次数'
                },
                {
                    title: '封面图片',
                    formatter: function (value, row, index) {
                        return $.table.imageView(row.imageUrl);
                    }
                },
                {
                    title: '文章内容',
                    formatter: function (value, row, index) {
                        myData.push(row);
                        // return '<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal5">大模态窗口</button>';
                        // return '<button type="button" class="btn btn-w-m btn-link" data-toggle="modal" data-target="#myModal5">详情</button>';
                        return '<a onclick="return showArticle(' + index + ');" data-toggle="modal" data-target="#myModal5">详情</a>';
                    }
                },
                {
                    field: 'tMenuName',
                    title: '文章类别'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });
</script>
</body>
</html>